package model;

import java.sql.*;
import java.util.ArrayList;

import connection.DbConnection;
import bean.Poll;
import bean.PollUser;


public class PollListImpl {
	
	private static PreparedStatement st;
	private static Connection conn;
	private static ResultSet rs;
		
	public static ArrayList<PollUser> showPollMaster(){
		ArrayList<PollUser> a = new ArrayList<PollUser>();
		
		try{
			rs = null;
			conn = new DbConnection().getConn();
	    	
			st = conn.prepareStatement("select * FROM PollUser WHERE accessibility = 2");
			rs=st.executeQuery();	
			
	    	while(rs.next()){
	    		PollUser pb = new PollUser();
	    		pb.setUsername(rs.getString(1));
	    		pb.setPassword(rs.getString(2));
	    		pb.setEmail(rs.getString(3));
	    		pb.setAccessibility(rs.getInt(4));
	    		pb.setFirstname(rs.getString(5));
	    		pb.setLastname(rs.getString(6));
	    		pb.setExpireDate(rs.getDate(7));
	    		pb.setCreateDate(rs.getDate(8));
	    		a.add(pb);
	    			
	    	}
	    	
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
				
		return a;				
		
	}

}
